﻿package com.tudou.home.newskin.containers
{
    import com.tudou.home.newskin.buttons.*;
    import com.tudou.home.newskin.events.*;
    import com.tudou.home.newskin.interfaces.*;
    import com.tudou.skin.common.button.*;
    import com.tudou.skin.common.events.*;
    import com.tudou.track.*;
    import flash.geom.*;

    public class VideoScale extends SelectRadioMenu implements IVideoScale
    {
        private var lastVideoScale:int;
        private var videoScaleButton:VideoScaleButton;

        public function VideoScale()
        {
            videoScaleButton = new VideoScaleButton();
            super(videoScaleButton, new VideoScaleRadio(), new Point(), new Point(0, videoScaleButton.height));
            activeIndex = VideoScaleType.ORGINAL;
            lastVideoScale = activeIndex;
            selected = false;
            return;
        }// end function

        public function setVideoScale(param1:Number) : void
        {
            var _loc_2:int = 0;
            if (Math.abs(param1 - 4 / 3) < 1e-010)
            {
                _loc_2 = 1;
            }
            else if (Math.abs(param1 - 16 / 9) < 1e-010)
            {
                _loc_2 = 2;
            }
            this.activeIndex = _loc_2;
            return;
        }// end function

        public function setOriginalVideoScale(param1:Boolean) : void
        {
            if (param1)
            {
                this.activeIndex = 0;
            }
            return;
        }// end function

        override protected function radioHlr(event:RadioEvent) : void
        {
            var _loc_3:Number = NaN;
            var _loc_2:* = event.clickIndex;
            if (_loc_2 == 0)
            {
                dispatchEvent(new SkinEvent(SkinEvent.SET_ORIGINAL_VIDEO_SCALE));
            }
            else if (_loc_2 == 1)
            {
                _loc_3 = 4 / 3;
                dispatchEvent(new SkinEvent(SkinEvent.SET_VIDEO_SCALE, _loc_3));
            }
            else if (_loc_2 == 2)
            {
                _loc_3 = 16 / 9;
                dispatchEvent(new SkinEvent(SkinEvent.SET_VIDEO_SCALE, _loc_3));
            }
            dispatchEvent(new SkinEvent(SkinEvent.BUTTON_LOG, SkinButtonCode.SCALE + "|" + lastVideoScale + "|" + _loc_2));
            lastVideoScale = _loc_2;
            return;
        }// end function

        override protected function selectHlr(event:SelectEvent) : void
        {
            selected = !event.selected;
            return;
        }// end function

    }
}
